import { WarScoreView } from "./WarScoreView";
import { SecTimerView } from "../common/SecTimerView";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SGuildWarScore } from "../../../../Message/Public/SGuildWarScore";
import { SGuildWarLeftNum } from "../../../../Message/Public/SGuildWarLeftNum";
import { Cache } from "../../cache/Cache";
import { Vector } from "../../../../__AS3__/vec/Vector";
type int = number;
//class GuildWarScoreView
    
    export  class GuildWarScoreView extends WarScoreView
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            this._tfLeftTime = new SecTimerView();
            this._tfLeftTime.x = 28;
            this._tfLeftTime.y = 10;
            this._tfLeftTime.width = 150;
            this._tfLeftTime.setParse(Language.getString(41823));
            this._tfLeftTime.defaultTextFormat = GlobalStyle.textFormat1;
            _spContent.addChild(this._tfLeftTime);
            ObjCreate.createTextField(Language.getString(41821), 28, 30, 62, 20, _spContent, GlobalStyle.textFormat5);
            this._tfGuildScore = ObjCreate.createTextField("0", 90, 30, 60, 20, _spContent);
            ObjCreate.createTextField(Language.getString(41822), 28, 50, 62, 20, _spContent, GlobalStyle.textFormat5);
            this._tfMyScore = ObjCreate.createTextField("0", 90, 50, 60, 20, _spContent);
            this._tfLeftLife = ObjCreate.createTextField("", 28, 70, 130, 20, _spContent, GlobalStyle.textFormat5);
            this._tfLeftLife.htmlText = Language.getStringByParam(41836, "3");
            var loc1=ObjCreate.createTextField(Language.getString(41852), 28, 90, 70, 20, _spContent, GlobalStyle.textFormat5);
            return;
        }

        protected /* override */ onShowDetailsHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            super.onShowDetailsHandler(arg1);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarGetScoreList));
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarShowOrHideStatusModule, true));
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._tfLeftTime.setLeftTime(arg1);
            return;
        }

        public updateScore(arg1: SGuildWarScore): void
        {
            this._tfGuildScore.text = arg1.battleMark.toString();
            this._tfMyScore.text = arg1.merits.toString();
            this._tfLeftLife.htmlText = Language.getStringByParam(41836, arg1.leftReviveTimes.toString());
            return;
        }

        public updateEnemyGuilds(arg1: SGuildWarLeftNum): void
        {
            var loc1=0;
            var loc3=0;
            var loc4=null;
            var loc5=0;
            if (!arg1) 
            {
                return;
            }
            if (!this.vcTFEnemyGuild) 
            {
                this.vcTFEnemyGuild = new Vector.<flash.text.TextField>();
                loc1 = 0;
                while (loc1 < 5) 
                {
                    if (loc1 != 0) 
                    {
                        this.vcTFEnemyGuild.push(ObjCreate.createTextField("", 28, 110 + 20 * loc1, 140, 20, _spContent));
                    }
                    else 
                    {
                        this.vcTFEnemyGuild.push(ObjCreate.createTextField("", 28, 110, 140, 20, _spContent, GlobalStyle.textFormatGreen));
                    }
                    ++loc1;
                }
            }
            var loc2="";
            loc1 = 1;
            if (Cache.instance.guild.myGuildInfo) 
            {
                this.vcTFEnemyGuild[0].text = Language.getStringByParam(41857, Cache.instance.guild.myGuildInfo.guildName, arg1.num.toString());
            }
            var loc6=0;
            var loc7=arg1.enemyNum;
            for (loc4 in loc7) 
            {
                loc3 = arg1.enemyNum[loc4];
                loc2 = Language.getStringByParam(41857, loc4, loc3.toString());
                if (!(this.vcTFEnemyGuild.length > loc1)) 
                {
                    continue;
                }
                this.vcTFEnemyGuild[loc1].text = loc2;
                ++loc1;
            }
            loc5 = loc1;
            while (loc5 < this.vcTFEnemyGuild.length) 
            {
                this.vcTFEnemyGuild[loc5].text = "";
                ++loc5;
            }
            return;
        }

        public static hasInstance(): Boolean
        {
            return !(GuildWarScoreView._instance == null);
        }

        public static get instance(): GuildWarScoreView
        {
            if (!GuildWarScoreView._instance) 
            {
                GuildWarScoreView._instance = new GuildWarScoreView();
            }
            return GuildWarScoreView._instance;
        }

        /* internal */ /* var */_tfGuildScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfMyScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLeftLife: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfLeftTime: SecTimerView;

        /* internal */ /* var */_tfTips: Object /* flash.text.TextField */;

        /* internal */ /* var */vcTFEnemyGuild: Vector.<flash.text.TextField>;

        /* internal */ static /* var */_instance: GuildWarScoreView;
    }
